package com.ly.thread;


import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyThread implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        System.out.println(Thread.currentThread().getName());
        return 0;
    }
}

public class CallableDemo {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask futureTask1 = new FutureTask(new MyThread());
        FutureTask futureTask2 = new FutureTask(new MyThread());
//        System.out.println(futureTask.get());


        new Thread(futureTask1,"A").start();
        new Thread(futureTask2,"B").start();


        System.out.println(futureTask1.get());
        System.out.println(futureTask2.get());
    }
}
